<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.js"></script>
</head>
<body>
    <div id="app">
        <p>使输入框自动获取光标</p>
        <input type="text">
        <input type="text" v-focus>
        <input type="text">
    </div>
    <script>
        // directive 指令
        // focus 聚焦 完整的名字是v-focus
        Vue.directive('focus', {
            // 配置项
            // inserted 插入，dom节点插入文档流时执行这个代码
            inserted: function(e) {
                console.log(11, e);
                e.focus()
            }
        })
        // 放在vue实例的前面
        let vm = new Vue({
            el: '#app',
            data: {
                
            }
        })
    </script>
</body>
</html>